#include <bits/stdc++.h>

using namespace std;

#define int long long

const int N = 1e5 + 10;
int dp[N];
int cost[N];

signed main()
{
    int n;
    cin >> n;
    for(int i = 0;i < n;i ++) cin >> cost[i];
    for(int i = 2;i <= n;i ++)
    {
        dp[i] = min(dp[i - 1] + cost[i - 1] , dp[i - 2] + cost[i - 2]);
    }
    cout << dp[n] << endl;
    return 0;
}